//
//  SLCameraHelper.h
//  SeewoLink
//
//  Created by guoqingwei on 16/5/13.
//  Copyright © 2016年 cvte. All rights reserved.
//

@import Foundation;
@import AVFoundation;
@import UIKit;

@protocol SLCameraTakePhotoDelegate <NSObject>

@optional
/**
 * Called when user tap the shot button and get the still image.
 */
- (void)cameraDidTakePhoto:(UIImage *)stillImage;

@end

@protocol SLCameraFrameCaptureDelegate <NSObject>

@optional
/**
 * Called when capture an image frame.
 */
- (void)cameraDidCaptureFrame:(UIImage *)imageFrame;

@end

@interface SLCameraHelper : NSObject

@property (nonatomic, weak) id <SLCameraTakePhotoDelegate> photodelegate;

@property (nonatomic, weak) id <SLCameraFrameCaptureDelegate> captureDelegate;

@property (strong, nonatomic, readonly) AVCaptureVideoPreviewLayer *previewLayer;

@property (readonly) AVCaptureDeviceInput *defaultDeviceInput;

@property (readonly) AVCaptureDeviceInput *frontDeviceInput;


+ (SLCameraHelper *)sharedInstance;

/**
 * @abstract Insert video preview layer to rootview, frame provided by captureView.
 * @param captureView
 * @param rootView
 */
- (void)insertSublayerWithCaptureView:(UIView *)captureView atRootView:(UIView *)rootView;

/**
 * @abstract Romove video preview layer from rootview.
 * set previewLayer to nil
 */
- (void)removePreviewLayer;

/**
 * @abstract Update previewLayer's frame to fit captureView
 */
- (void)updatePreviewLayer;

/**
 * @abstract AVCaptureSession start running.
 */
- (void)startRunning;

/**
 * @abstract AVCaptureSession stop running.
 */
- (void)stopRunning;

/**
 * @abstract Take Photo from Session. The still image will return form delegate.
 * @param videoOrientation Device orientation when taka photo.
 * @param cropSize Crop size of origin image size.
 */
- (void)takePhotoWithOrientation:(UIDeviceOrientation)videoOrientation cropSize:(CGSize)cropSize;


- (void)captureImageFrameWithOrientation:(UIDeviceOrientation)videoOrientation cropSize:(CGSize)cropSize;


@end
